
package managedbean.Customer;

import entity.LineItem;
import entity.PurchaseOrder;
import entity.Customer;
import java.io.Serializable;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import session.stateless.PurchaseOrderBeanLocal;


@ManagedBean(name="viewCustomersPurchaseOrders")
@ViewScoped
public class ViewCustomersPurchaseOrdersManagerBean implements Serializable{

    public ViewCustomersPurchaseOrdersManagerBean() {
    }
    
    @EJB
    private PurchaseOrderBeanLocal purchaseOrderBeanLocal;
    private Customer selectedCustomer;
    private List<PurchaseOrder> selectedPurchaseOrders;
    private List<LineItem> lineItems;
    private String statusMessage;
    
    public void initView(PhaseEvent event)
    {
        selectedCustomer = (Customer)FacesContext.getCurrentInstance().getExternalContext().getFlash().get("selectedCustomer");            
        selectedPurchaseOrders = purchaseOrderBeanLocal.getPurchaseOrdersByCustomer(selectedCustomer.getRegistrationNumber());
    }

    public Customer getSelectedCustomer() {
        return selectedCustomer;
    }

    public void setSelectedCustomer(Customer selectedCustomer) {
        this.selectedCustomer = selectedCustomer;
    }

    public PurchaseOrderBeanLocal getPurchaseOrderBeanLocal() {
        return purchaseOrderBeanLocal;
    }

    public void setPurchaseOrderBeanLocal(PurchaseOrderBeanLocal purchaseOrderBeanLocal) {
        this.purchaseOrderBeanLocal = purchaseOrderBeanLocal;
    }

    public List<PurchaseOrder> getSelectedPurchaseOrders() {
        return selectedPurchaseOrders;
    }

    public void setSelectedPurchaseOrders(List<PurchaseOrder> selectedPurchaseOrders) {
        this.selectedPurchaseOrders = selectedPurchaseOrders;
    }

    public String getStatusMessage() {
        return statusMessage;
    }

    public void setStatusMessage(String statusMessage) {
        this.statusMessage = statusMessage;
    }

    public List<LineItem> getLineItems() {
        return lineItems;
    }

    public void setLineItems(List<LineItem> lineItems) {
        this.lineItems = lineItems;
    }
    
    public List<PurchaseOrder> getPurchaseOrder(){
        return purchaseOrderBeanLocal.getPurchaseOrders();
    }

}